
#ifndef CORE_H
#define CORE_H

#define PATCH_SIZE 60
#define PATCH_SHIFT 15
#define NEARBY 15
#define NXBIN 18
#define NYBIN 6
#define NTHBIN 4
#define DES_LEN 432
#define TOP_RATIO 0.2
#define SKETCH_SIZE 3
#define NUM_SKETCH_PER_DES 20
#define CANDIDATE 30

#include <stdio.h>

#include <string>
#include <iostream>
using namespace std;

class Sketch
{
	public:
		Sketch(){;}
		Sketch(int v[SKETCH_SIZE]) {
			for(int i=0;i<SKETCH_SIZE;i++) tuple[i] = v[i];
		}
		int tuple[SKETCH_SIZE];
		bool operator<(const Sketch &s) const{
			int i;
			for(i=0;i<SKETCH_SIZE;i++){
				if(tuple[i] < s.tuple[i])
					return true;
				else if(tuple[i] > s.tuple[i])
					return false;
			}
			return false;
		}
		bool operator==(const Sketch &s) const{
			int i=0;
			for(i=0;i<SKETCH_SIZE;i++)
				if(tuple[i] != s.tuple[i])
					return false;
			return true;
		}
		friend ostream & operator<<(ostream &out, const Sketch &s) {
			for(int i=0;i<SKETCH_SIZE;i++)
				out << s.tuple[i] << " ";
			return out;
		}
		friend istream & operator>>(istream &in, Sketch &s) {
			for(int i=0;i<SKETCH_SIZE;i++)
				in >> s.tuple[i];
			return in;
		}
};

class Position
{
	public:
		Position(){};
		Position(int _y,int _x) {y=_y;x=_x;}
		int y;
		int x;
		friend ostream & operator<<(ostream &out, const Position &p) {
			out << p.y << " " << p.x << " ";
			return out;
		}
		friend istream & operator>>(istream &in, Position &p) {
			in >> p.y >> p.x; return in;
		}
};

class Record
{
	public:
		Record(){}
		Record(Position p, int id) { position = p; fileID = id;}
		Position position;
		int fileID;
		inline bool operator<(const Record &r) const{
			if (fileID < r.fileID )
				return true;
			else if(fileID > r.fileID)
				return false;
			else if( position.x < r.position.x)
				return true;
			else if( position.x > r.position.x)
				return false;
			else if( position.y < r.position.y)
				return true;
			else if( position.y > r.position.y)
				return false;
			return false;
		}
		friend ostream & operator<<(ostream &out, const Record &r) {
			out << r.fileID << " " << r.position << " " ;
			return out;
		}
		friend istream & operator>>(istream &in, Record &r) {
			in >> r.fileID >> r.position; return in;
		}
		inline bool operator==(const Record  &r) const {
			return position.x == r.position.x && position.y == r.position.y && fileID == r.fileID;
		}
};

#endif
